package com.mjlf.test_shiro.config;

import com.mjlf.test_shiro.entity.Person;
import com.mjlf.test_shiro.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @ClassName: SwaggerConfig
 * @Author: majun
 * @CreateDate: 2018/10/17 16:10
 * @Version: 1.0
 * @Description: TODO
 */

@EnableSwagger2
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(createApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mjlf.test_shiro.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public ApiInfo createApiInfo() {
        return new ApiInfoBuilder()
                .title("测试使用Swagger")
                .termsOfServiceUrl("http://localhost:8080/test_shiro")
                .version("1.0.0")
                .description("练习使用swagger").build();
    }
}
